var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("GameConstant"),
l = cc._decorator,
c = l.ccclass,
d = (l.property,
function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.bShowIn = !1,
        e.bCarCollider = !1,
        e.bCarWheelCollider = !1,
        e.bWheelCollider = !1,
        e.bBouting = !1,
        e._gameControl = null,
        e._carTag = 0,
        e._carPos = null,
        e.nCurTime = 0,
        e
    }
    return n(e, t),
    e.prototype.initView = function(t, e, o) {
        this.node.active = !1,
        this._gameControl = t,
        this._carTag = e,
        r.default.nCurGameType == s.Game_Type.PK ? this._carPos = o: r.default.nCurGameType == s.Game_Type.PK_1 ? this._carPos = cc.v3(o.x, o.y + 200, o.z) : r.default.nCurGameType == s.Game_Type.PK_2 ? this._carPos = cc.v3(o.x, o.y, o.z) : this._carPos = o,
        this.bCarCollider = !1,
        this.bCarWheelCollider = !1,
        this.bWheelCollider = !1,
        this.bShowIn = !1
    },
    e.prototype.onCancelHarpoon = function(t) {
        console.log("被飞碟传送取消钩中状态"),
        this._gameControl && this._gameControl.onHarpoon(t, !1),
        this._gameControl && this._gameControl.onCanAttack(t, !0)
    },
    e.prototype.onGameBoutStart = function() {
        this.bBouting = !0,
        this.nCurTime = 0,
        this.nCurTime = 0,
        this.bCarCollider = !1,
        this.bCarWheelCollider = !1,
        this.bWheelCollider = !1
    },
    e.prototype.onGameBoutOver = function() {
        this.bBouting = !1,
        this.node.stopAllActions(),
        this.nCurTime = 0,
        this.bCarCollider = !1,
        this.bCarWheelCollider = !1,
        this.bWheelCollider = !1,
        this.node.active = !1
    },
    e.prototype.onCarAngle = function(t, e) {
        this.bBouting && (this.bCarCollider || this.bWheelCollider || this.bCarWheelCollider ? this.isDistance() : this.bShowIn || (this._carTag == s.Collide_Car_Tag.Left ? this._gameControl._carLeftView.getScaleX() < 0 && (t = -t) : this._carTag == s.Collide_Car_Tag.Right && this._gameControl._carRightView.getScaleX() < 0 && (t = -t), (t %= 360) < 0 && (t += 360), t > 90 && t < 270 ? this.onStartTime(e) : this.onEndedTime()))
    },
    e.prototype.onStartTime = function(t) {
        this.nCurTime += t,
        this.nCurTime > 3 && this.playShowIn()
    },
    e.prototype.onEndedTime = function() {
        this.nCurTime = 0
    },
    e.prototype.onCollideCarBody = function(t, e, o) {
        "bodyBody" == t ? (e && (this.bCarCollider = !0, this.onEndedTime()), o && (this.bCarCollider = !1)) : "bodyWheel" == t && (e && (this.bCarWheelCollider = !0, this.onEndedTime()), o && (this.bCarWheelCollider = !1))
    },
    e.prototype.onCollideCarWheel = function(t, e, o) {
        e && (this.bWheelCollider = !0, this.onEndedTime()),
        o && (this.bWheelCollider = !1)
    },
    e.prototype.playShowIn = function() {
        var t = this;
        this.onEndedTime(),
        this.bShowIn || (this.nCurTime = 0, this.bShowIn = !0, this.onCancelHarpoon(this._carTag), this._gameControl.onAirShipIn(this._carTag), this.node.position = cc.v3(this._carPos.x, this._carPos.y + cc.winSize.height, 0), this.node.active = !0, cc.tween(this.node).to(1, {
            position: cc.v3(this._carPos.x, this._carPos.y + 150, 0)
        }).call(function() {
            t.bBouting && t._gameControl.onAirShipOut(t._carTag, t._carPos)
        }).delay(1).call(function() {
            t.bBouting && t.playShowOut()
        }).start())
    },
    e.prototype.playShowOut = function() {
        var t = this;
        cc.tween(this.node).by(1, {
            position: cc.v3(0, cc.winSize.height, 0)
        }).call(function() {
            t.node.active = !1,
            t.bShowIn = !1
        }).start()
    },
    e.prototype.isDistance = function() {
        var t = this._gameControl._carLeftView.getCarWorldPos(),
        e = this._gameControl._carRightView.getCarWorldPos(),
        o = this._gameControl._carLeftView.getCarBodyWidth(),
        i = this._gameControl._carRightView.getCarBodyWidth();
        Math.abs(e.x - t.x) > (o + i) / 2 && (this.bCarCollider = !1, this.bCarWheelCollider = !1, this.bWheelCollider = !1)
    },
    a([c], e)
} (cc.Component));
o.default = d